<!-- 变更记录 -->
<template>
  <dt-modal-info class="change_log" ref='logDetail' :line-number='3' :title='title'
    :label-width='60' :width='800'>
    <div slot='bottom' style="padding: 0 0 50px 0" v-show="type=='check'">
      <dt-grid height-resize ref='changeLogTable' :list='tableList'>
      </dt-grid>
    </div>
    <div slot='bottom' style="padding: 0 0 50px 0" v-show="type=='edit'">
      <change-table ref="changeTable" @changeTableSuccess='onChangeTableSuccess' />
    </div>
  </dt-modal-info>
</template>

<script>
  import changeTable from './changeLogTable.vue'
  import Opt from './opt/changeLog'
  import Column from './opt/changeLogColumn'
  import teamsApi from '@/biz/buildingManagement/teams'
  export default {
    components: { changeTable },
    data() {
      return {
        title: '变更记录',
        info: null,
        tableList: [],
        type: '',
      };
    },

    methods: {
      show(data, type) {
        this.info = data
        this.type = type
        this.$refs.logDetail.show(new Opt(this.info))
        this.init()
      },
      //请求变更记录数据
      init() {
        let params = {
          workNo: this.info.workNo,
          teamId: this.info.teamId,
          groupId: this.info.groupId
        }
        teamsApi.changeRecordQuery({ ...params }).then((res) => {
          console.log(res)
          this.tableList = res
          if (this.type == 'check') {
            this.$refs.changeLogTable.init(this, new Column(this), this.type)
          } else {
            res && res.forEach(item => { item.workNo = this.info.workNo })
            this.$refs.changeTable.btnFlag = false
            this.$refs.changeTable.tableList = res
          }
        })
      },
      onChangeTableSuccess() {
        this.$emit('success')
      }
    },
  }
</script>
<style lang='scss' scoped>
  .change_log {
    .operate_btn {
      color: #2d8cf0;
    }
  }
</style>